<!Doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>信息修改...</title>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../css/main.css"/>
    <script type="text/javascript" src="../js/modernizr.min.js"></script>
    <script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="../js/getParameter.js"></script>

    <script>
        $(function () {
            $("#header").load("../static/header.html");
            $("#left").load("../static/left.html");

            //获取orderId 填写表单
            var orderId = getParameter("orderId");
            var buyersId = getParameter("uid");
            //填充地址信息
            $.post("../address/getAddress.do", {uid:buyersId}, function (data) {
                var ops = "";
                for (let i = 0; i < data.length; i++) {
                    ops += "<option value='" + data[i].addressId + "'>" + data[i].address + "</option>";
                }
                $("#addressId").html(ops);
            });
            //修改  1.回显数据
            $.get("../order/getOrderOne.do", {orderId: orderId}, function (data) {
                $("#orderId").val(data.orderId);
                $("#name").val(data.addressId.name);
                $("#phone").val(data.addressId.phone);
                $("#totalPrice").val(data.totalPrice);
                $("#addressId").find("option[value='" + data.addressId.addressId + "']").attr("selected", true);
            });
            //修改操作
            $("#myform_uporder").submit(function () {
                $.post("../order/upOrder.do",$(this).serialize(),function (data) {
                    if(data != null){
                        alert(data.errorInfo);
                        if (data.errorType == 0){
                            //返回上级目录
                            history.go(-1);
                        }
                    }
                });
                //取消表单提交  改用ajax交互
                return false;
            });
        });
    </script>
</head>
<body>

<div class="container clearfix">
    <div id="header"></div>
    <div id="left"></div>
    <!--/sidebar-->
    <div class="main-wrap">
        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="userManage.html">用户管理</a><span
                    class="crumb-step">&gt;</span><span class="crumb-name">用户信息修改</span></div>
        </div>
        <div class="result-wrap">
            <form action="../order/upOrder.do" method="post" id="myform_uporder">
                <div class="config-items">
                    <div class="config-title">
                        <h1><i class="icon-font">&#xe00a;</i>订单修改</h1>
                    </div>
                    <div class="result-content">
                        <table width="100%" class="insert-tab">
                            <tbody>
                            <tr>
                                <th width="15%"><i class="require-red">*</i>订单编号：</th>
                                <td><input id="orderId" value="" name="orderId" readonly></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>收货人：</th>
                                <td><input type="text" name="name" id="name" class="common-text" readonly></td>
                            </tr>
                            <tr>
                                <th><i class="require-red" readonly>*</i>收货人号码：</th>
                                <td><input type="text" name="phone" id="phone" class="common-text" readonly></td>
                            </tr>
                            <tr>
                                <th><i class="require-red" readonly>*</i>总价：</th>
                                <td><input type="text" name="totalPrice" id="totalPrice" class="common-text"></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>收货地址：</th>
                                <td>
                                    <select name="addressId.addressId" id="addressId">
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <!--<input type="submit" value="提交" class="btn btn-primary btn6 mr10">-->
                                    <input type="submit" value="修改" class="btn btn-primary btn6 mr10" id="submit">
                                    <input type="button" value="返回" onclick="history.go(-1)" class="btn btn6">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>